Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there, This PR resolves issue #382. @miliadis and I worked together and successfully resolved this issue by having the aspect ratio and resize method adapt when width > height and height > width. Currently the cropped regions in
horizontal_list
andfree_list
are resized so the height fits themodel_height
(L523 and L543).The image resizing is calculated by computing the aspect ratio, which is width/height (L522 and L542). Assuming the aspect ratio should only be calculated as width/height results in a bug when the cropped region resolution is reduced. When height>width, aspect ratio is <1.0, which results in the resolution of the image being significantly reduced. This then results in poor performance in the CRNN to recognize the text, even when you set the Reader to recognize in several orientations.
Our solution flips the resizing and aspect ratio calculation when the aspect ratio is < 1.0.
To ensure that the max_width is correctly captured, we also updated the make_rotated_img_list() function to capture the max_width in all orientation configurations.
Here is an example notebook that shows the latest EasyOCR performance on a simple text in vertical orientation.
https://colab.research.google.com/drive/1df-dv7IUF0AzaWUwizRspeHr59lm7aeP?authuser=1#scrollTo=-VepZ4LZXMD-
[([[1, 1], [21, 1], [21, 127], [1, 127]], 'W', 0.3783025082953806)]
And here is a demo with our solution showing EasyOCR can now recognize vertical text:
https://colab.research.google.com/drive/1uDXl8yd18LLPsnSd2jFZ3kj0B5_-lkjk?authuser=1#scrollTo=CU8FzHcoIgCv
[([[1, 1], [21, 1], [21, 127], [1, 127]], 'coronavirus', 0.6846225781041564)]